//
//  STLimitHeaderView.m
//  CuiBoStore
//
//  Created by 崔博 on 16/12/6.
//  Copyright © 2016年 崔博. All rights reserved.
//

#import "STLimitHeaderView.h"
#import "SDCycleScrollView.h"
#import "STBannerModel.h"
@interface STLimitHeaderView()<SDCycleScrollViewDelegate>
@property (strong, nonatomic) SDCycleScrollView *bannerView;
@end

@implementation STLimitHeaderView

+ (instancetype)limitHeaderView
{
    return [[[NSBundle mainBundle] loadNibNamed:@"STLimitHeaderView" owner:nil options:nil] firstObject];
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    self.size = CGSizeMake(SCREEN_WIDTH, 280);
    [self addSubview:self.bannerView];
}
#pragma mark - event
- (IBAction)clickIndex:(id)sender {
    self.block(((UIButton *)sender).tag);
}
#pragma mark - set
- (void)setBannerArray:(NSArray *)bannerArray
{
    _bannerArray = bannerArray;
    NSMutableArray *imageArray = [NSMutableArray array];
    NSMutableArray *titileArray = [NSMutableArray array];
    for (STBannerModel *m in bannerArray) {
        [imageArray addObject:m.imgView];
        [titileArray addObject:m.commodityText];
    }
    self.bannerView.imageURLStringsGroup = imageArray;
    self.bannerView.titlesGroup = titileArray;
}
- (SDCycleScrollView *)bannerView
{
    if (!_bannerView) {
        _bannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 230) delegate:self placeholderImage:[UIImage imageNamed:@"详情界面购物车按钮"]];
        _bannerView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
    }
    return _bannerView;
}
@end
